package bloomfilter;

import com.sun.webkit.network.URLs;
import sun.text.resources.cldr.ii.FormatData_ii;

/**
 * @Author: LDeng
 * @Date: 2021-04-28 16:48
 */
public class Main {


    public static void main(String[] args) {
        BloomFilter<Integer> bf = new BloomFilter<>(1_0_0000, 0.00001);
        for (int i = 1; i < 100000; i++) {
            bf.put(i);
        }

        int count=0;
        for (int i = 100001; i < 200000; i++) {
            if(bf.contains(i)){
                count++;
            }
        }
        System.out.println("误判次数："+count);
//        bf.put("asdfadsfa");
//        bf.contains("asdfadsfa");



    }

    static void testUrl(){
        //爬虫案例
        String[] urls={"aa","bb"};

        BloomFilter<String> bf=new BloomFilter<>(10_0000_0000,0.01);
        for(String url: urls){
            if(bf.contains(url)) continue;//返回true表示爬过，直接跳过
            //爬取url 放入布隆过滤器
            //.....爬取业务
            bf.put(url);
        }
    }


}
